#include "iqtest.h"
#include "xmppcore/iq.h"

#include <QtTest/QTest>

namespace yoohoo_xmppcore {

QString Ping::toXml() {
	return "<ping xmlns='urn:xmpp:ping'/>";
}

void IqTest::testToXml() {
	QString xml =
		"<iq type='get' id='s2c1' from='capulet.lit' to='juliet@capulet.lit/balcony'>"
			"<ping xmlns='urn:xmpp:ping'/>"
		"</iq>";

	Iq iq;
	JabberId from("capulet.lit"), to("juliet", "capulet.lit", "balcony");
	iq.setFrom(&from);
	iq.setTo(&to);
	iq.setId("s2c1");
	iq.setIqType(Iq::IqTypeGet);

	Ping* ping = new Ping();
	iq.setObj(ping);

	QCOMPARE(xml, iq.toXml());
}

}

QTEST_MAIN(yoohoo_xmppcore::IqTest);
